#include "test.h"

char data_test[17] = {
1,2,3, '+',
4,5,6, '-',
7,8,9, '*',
'a',0,'=','/', 16
};

void tset()
{
		char ch1 = 0;
		char ch2 = 0;
		int num1 = 0;
		int num2 = 0;
		int num3 = 0;
		num1 = transition_num(&ch1);
		num2 = transition_num(&ch2);
		if(ch2 == '=')
		{
				if(ch1 == '+')
				{	
				num3 = num2 + num1;
				count(num3);
				}
				if(ch1 == '-')
				{
					num3 = num1 - num2;
					count(num3);
				}
					if(ch1 == '*')
				{
					num3 = num1 * num2;
					count(num3);
				}
					if(ch1 == '/')
				{
					num3 = num1 / num2;
					count(num3);
				}
		}
}


char transition_char(void)
{
return data_test[scan_key_1()];
}
int transition_num(char * ch)
{
		int num_1 = 0;
		int num_2 = 0;
		while(num_1 <= 16)
		{
			num_1 = transition_char();
			if(num_1 >= 0 && num_1 <= 10 && P3 != 0xF0)
			{
				num_2 = 10 * num_2 + num_1;
			}
			Show_Num(num_2);
		}
		switch(num_1)
		{
			case '+' : Show_Num(1111); break;
			case '-' : Show_Num(2222); break;
			case '*' : Show_Num(3333); break;
			case '/' : Show_Num(4444); break;
		
		}
		*ch = num_1;
		return num_2;
}	
int count(int num3)
{
	char ch1 = 0;
	while(1)
	{
		Show_Num(num3);
		ch1 = transition_char();
		if(ch1 == 'a')
		{
			num3 = 0;
			Show_Num(num3);
			break;
		}
	}
	return 0;
}